<template>
  <div v-if="attentionList">
    <perNav center="我的关注"></perNav>
    <div class="attentionBar" v-for="(item,index) of attentionList" :key="index">
      <div class="photo">
        <img :src="$axios.defaults.baseURL+  item.head_img" alt />
      </div>

      <p class="nickname">{{item.nickname}}</p>

      <span class="cancel" @click="cancel(item.id)">取消关注</span>
    </div>
  </div>
</template>

<script>
import perNav from "../../components/perNav";
export default {
  data() {
    return {
      attentionList: []
    };
  },
  components: {
    perNav
  },
  methods: {
    get_attention() {
      this.$axios({
        method: "get",
        url: "/user_follows"
      }).then(res => {
        console.log(res);
        const { data } = res.data;
        this.attentionList = data;
      });
    },
    cancel(id) {
      this.$axios({
        method: "get",
        url: "/user_unfollow/" + id
      }).then(res => {
        this.$notify({ type: "success", message: res.data.message });
        this.get_attention();
      });
    }
  },
  mounted() {
    this.get_attention();
  }
};
</script>

<style lang="less" scoped>
.attentionBar {
  padding: 5.556vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  .photo {
    width: 13.889vw;
    height: 13.889vw;
    > img {
      width: 100%;
      height: auto;
      border-radius: 50%;
      background-color: #ccc;
    }
  }
  .nickname {
    padding-left: 2.778vw;
    flex: 1;
  }
  .cancel {
    width: 22.222vw;
    height: 9.722vw;
    line-height: 9.722vw;
    color: white;
    border-radius: 4.861vw;
    text-align: center;
    background-color: #31c37b;
    font-size: 3.889vw;
  }
}
</style>